package com.example.rbac.aop;

import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.JdkRegexpMethodPointcut;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class InterceptorAnnotationConfig {


    @Bean
    public DefaultPointcutAdvisor defaultPointcutAdvisor(){
        TestInterceptor interceptor = new TestInterceptor();

//         AnnotationMatchingPointcut pointcut = new AnnotationMatchingPointcut(Test.class);
        JdkRegexpMethodPointcut pointcut = new JdkRegexpMethodPointcut();
        pointcut.setPatterns("com.example.rbac.service.impl.*");

        // 配置增强类advisor
        DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
        advisor.setPointcut(pointcut);
        advisor.setAdvice(interceptor);
        return advisor;

    }
}
